
##################################################################################################

#  Description: Generating Figure 1 from Fleming, Thomas G. and Schleiter, Petra, (Forthcoming)
#               'Prorogation: Comparative Context and Scope for Reform', Parliamentary Affairs
#  Date:        01/06/2020
#  Note:        Requires file "data.csv" to be saved in same folder

##################################################################################################

rm(list=ls())


library(ggplot2)


library(rstudioapi)                               # sets wd as current folder
current_path <- getActiveDocumentContext()$path
setwd(dirname(current_path))

#################################
# Loading and reformatting data #
#################################

  # loads data showing proportion of MPs which can insist on a sitting, and average seat share of opposition parties

  data <- read.csv("./data.csv")

  # reformats proportions to percentages, for presentation purposes

  data$prop_insist <- 100*data$prop_insist
  data$average_opp_share <- 100*data$average_opp_share

##################################################################################################
# Figure 1                                                                                       #
#  The share of MPs able to request a sitting, plotted against the average opposition seat share #
##################################################################################################
  
  ggplot(data, aes(x = prop_insist, y = average_opp_share))+
    geom_point()+
    geom_abline(slope = 1, intercept = 0)+
    theme_classic()+
    xlab("\nPercentage of MPs able to insist on a sitting")+
    ylab("Average seat % of opposition parties\n")+
    scale_y_continuous(limits = c(0, 61))+
    scale_x_continuous(limits = c(0, 60))+
    theme(legend.background = element_rect(linetype = "solid", size = 0.3, colour = "black"),
          legend.title=element_blank(),
          axis.title.y = element_text(face = "bold"),
          axis.title.x = element_text(face = "bold"),
          panel.border = element_rect(colour = "black", fill = NA, size = 0.7), # adds rectangle
          axis.line = element_blank())                                          # removes axis lines
  
  ggsave("./figure1.png", width = 5, height = 4, units = "in")
    
##################################################################################################

rm(list = ls())
  